package com.xlisteven.controller;

import com.xlisteven.service.IFruitsService;
import com.xlisteven.entity.Fruits;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("fruit")
public class FruitsController {

    @Autowired
    IFruitsService fruitsService;

    @GetMapping("getFruitsList/{userId}")
    public List<?> getFruitsList(@PathVariable(name = "userId") Long userId) {
        List<Fruits> fruitsList = fruitsService.getFruitsList(userId);
        return fruitsList;
    }

    @PostMapping("insert")
    public void insert(@RequestBody List<Fruits> fruitsList){
        fruitsService.insert(fruitsList);
    }
}
